<?php
/**
 * Created by PhpStorm.
 * User: peter
 * Date: 18-9-18
 * Time: 下午3:58
 */

namespace app\admin\controller;



use think\Request;

class CollectionPoint extends Auth
{
    /**
     * @purpose 添加集合点(支持批量添加)
     * @param Request $request
     * @return array
     * @throws \think\exception\PDOException
     */
    public function add (Request $request)
    {
        $data = $request->post();
        return \app\admin\logic\CollectionPoint::add($data);
    }

    /**
     * @purpose 通过ID修改上车点信息
     * @param Request $request
     * @return array
     */
    public function edit (Request $request)
    {
        $data = $request->post();
        return \app\admin\logic\CollectionPoint::edit($data);
    }

    /**
     * @purpose 通过id删除上车地点
     * @param Request $request
     * @return array
     * @throws \Exception
     */
    public function delete (Request $request)
    {
        $ids = $request->post();
        return \app\admin\logic\CollectionPoint::delete($ids);
    }

    /**
     * @purpose 通过俱乐部ID获取上车地点
     * @param Request $request
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function items (Request $request)
    {
        $province_name = $request->get('province_name','');
        $city_name     = $request->get('city_name','');
        $county_name   = $request->get('county_name','');
        $page          = $request->get('page',1);
        $size          = $request->get('size', 50);
        return \app\admin\logic\CollectionPoint::items($province_name,$city_name,$county_name,$page,$size);
    }

    /**
     * @purpose 通过市级ID获取上车集合点
     * @param Request $request
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function itemsByCity (Request $request)
    {
        $city_id        = $request->get('city', 0);
        return \app\admin\logic\CollectionPoint::itemsByCity($city_id);
    }
}